/**
 * Created by Administrator on 2015/11/10.
 */
// "/static/js/jquery-1.10.2/jquery.plugins.js","/static/js/jquery-1.10.2/mousewheel/jquery.mousewheel.min.js"
/* "/static/js/jquery-1.10.2/jquery.plugins.js" */

(function ($) {
    var scrollIncrement = 100;
    var scrollDuration = 400;
    var tabsContainer = null;
    var tabsLeftScroll = null;
    var tabsRightScroll = null;
    var panelsContainer = null;
    var secondTabsContainer = null;
    $.fn.tabs = function (options, param) {
        if (typeof options == 'string') {
            switch (options) {
                case'add':
                    return addTab(param);
                case'close':
                    return closeTab(param);
                case'select':
                    return selectTab(param);
                case'exists':
                    return exists(param);
                case'selected':
                    return selected();
                default:
                    return;
            }
        }
        tabsContainer = this;
        scrollIncrement = options.scrollIncrement || scrollIncrement;
        scrollDuration = options.scrollDuration || scrollDuration;
        tabsLeftScroll = $('#' + options.tabsLeftScroll) || tabsLeftScroll;
        tabsRightScroll = $('#' + options.tabsRightScroll) || tabsRightScroll;
        panelsContainer = $('#' + options.panelsContainer) || panelsContainer;
        secondTabsContainer = $('#' + options.secondTabsContainer) || panelsContainer;
        tabsContainer.bind('_resize', function () {
            if (tabsContainer.outerWidth() < tabsContainer[0].scrollWidth) {
                tabsLeftScroll.show();
                tabsRightScroll.show();
            }
            else {
                tabsLeftScroll.hide();
                tabsRightScroll.hide();
            }
        });
        tabsLeftScroll.hover(function () {
            $(this).addClass('active');
        }, function () {
            $(this).removeClass('active');
        });
        tabsRightScroll.hover(function () {
            $(this).addClass('active');
        }, function () {
            $(this).removeClass('active');
        });
        tabsLeftScroll.bind('click', function () {
            var scrollTo = tabsContainer.scrollLeft() - scrollIncrement;
            if (scrollTo < scrollIncrement)
                scrollTo = 0;
            tabsContainer.animate({scrollLeft: scrollTo}, scrollDuration);
        });
        tabsRightScroll.bind('click', function () {
            var scrollTo = tabsContainer.scrollLeft() + scrollIncrement;
            if (scrollTo + scrollIncrement > tabsContainer.attr('scrollWidth'))
                scrollTo = tabsContainer.attr('scrollWidth');
            tabsContainer.animate({scrollLeft: scrollTo}, scrollDuration);
        });
        tabsContainer.delegate('div > a.tab', 'click', function () {
            selectTab($(this).attr('index'));
        });
        tabsContainer.delegate('div > a.tab', 'mousedown', function (event) {
            if (!window.addEventListener && event.button == 4 || window.addEventListener && event.button == 1) {
                if ($(this).attr('closable') == "true") {
                    closeTab($(this).attr('index'));
                }
            }
        });
        tabsContainer.delegate('div > a.tab', 'dblclick', function () {
            if ($(this).attr('closable') == "true")
                closeTab($(this).attr('index'));
        });
        tabsContainer.delegate('div > a.close', 'click', function () {
            closeTab($(this).attr('index'));
        });
    };
    function addTab(param) {
        $("#tosbg").length > 0 && $("#tosbg").hide();
        if (!param.id)return;
        if (exists(param.id)) {
            selectTab(param.id);
            return;
        }
        param.callback();
        var html = '<div id="tabs_' + param.id + '"><a href="javascript:;" id="tabs_link_' + param.id + '" class="tab" index="' + param.id + '" closable="' + param.closable + '" hidefocus="hidefocus">' + param.title + '</a>';
        if (param.closable)
            html += '<a href="javascript:;" class="close" index="' + param.id + '" hidefocus="hidefocus"></a>';
        html += '</div>';
        $(html).appendTo(tabsContainer);
        $('<div id="tabs_' + param.id + '_panel" class="tabs-panel" style="' + param.style + '">' + param.content + '</div>').appendTo(panelsContainer);
        tabsContainer.triggerHandler('_resize');
        if (param.selected)
            selectTab(param.id);
    }

    function closeTab(id) {
        var iframe = window.frames['tabs_' + id + '_iframe'];
        try {
            if (iframe && typeof(iframe.onclose) == 'function') {
                if (!iframe.onclose())
                    return;
            }
        } catch (e) {
        }
        var nextTab = $('#tabs_' + id, tabsContainer).next();
        $('#tabs_' + id + '_iframe').remove();
        $('#tabs_' + id, tabsContainer).remove();
        $('#tabs_' + id + '_panel', panelsContainer).remove();
        $('#second_tabs_' + id, secondTabsContainer).remove();
        if (!nextTab.is('div'))
            nextTab = $('div', tabsContainer).last();
        var nextId = nextTab.attr('id');
        tabsContainer.triggerHandler('_resize');
        tabsContainer.triggerHandler('_close');
        if ($("#center .tabs-panel").length <= 0) {
            $("#tosbg").length > 0 && $("#tosbg").show();
        }
        else {
            $("#tosbg").length > 0 && $("#tosbg").hide();
        }
        if (nextId) {
            selectTab(nextId.substr(5));
        }
        if (navigator.userAgent.indexOf('MSIE') >= 0)
            CollectGarbage();
    }

    function selectTab(id) {
        $("#tosbg").length > 0 && $("#tosbg").hide();
        $('body').removeClass('showSearch').removeClass('right-mini');
        $('#eastbar,#searchbar').removeClass('on');
        if (navigator.userAgent.indexOf('iPad') > 0) {
            $('#east').addClass('mobile-east').hide();
        }
        if (!exists(id))return;
        $('div', tabsContainer).removeClass('selected');
        var $selected = $('.tabs-panel.selected', panelsContainer).removeClass('selected fadeInDown');
        $('#tabs_' + id, tabsContainer).addClass('selected');
        $('#tabs_' + id + '_panel', panelsContainer).addClass('selected').addClass("animated");
        if (!$('#tabs_' + id + '_iframe').attr('src') && $('#tabs_' + id + '_iframe').attr('_src')) {
            $('#tabs_' + id + '_iframe').attr('src', $('#tabs_' + id + '_iframe').attr('_src'));
        }
        else {
            var iframe = window.frames['tabs_' + id + '_iframe'];
            if (iframe && typeof(iframe.onactive) == 'function')
                iframe.onactive();
        }
        if (typeof(SetWin8Style) == 'function')
            SetWin8Style($('#tabs_' + id + '_iframe').attr('src'));
        scrollTabVisible(id);
    }

    function exists(id) {
        return $('#tabs_' + id, tabsContainer).length > 0;
    }

    function selected() {
        return $('div.selected:first', tabsContainer).attr('id').substring(5);
    }

    function scrollTabVisible(id) {
        var tabsOffsetLeft = $('#tabs_' + id, tabsContainer).offset().left;
        var tabsWidth = $('#tabs_' + id, tabsContainer).outerWidth();
        var containerOffsetLeft = tabsContainer.offset().left;
        var containerWidth = tabsContainer.outerWidth();
        var containerScrollLeft = tabsContainer.scrollLeft();
        if (tabsOffsetLeft > containerOffsetLeft && tabsOffsetLeft + tabsWidth > containerOffsetLeft + containerWidth) {
            var scrollTo = (tabsOffsetLeft + tabsWidth) - (containerOffsetLeft + containerWidth) + containerScrollLeft;
            tabsContainer.animate({scrollLeft: scrollTo}, scrollDuration);
        }
        else if (tabsOffsetLeft < containerOffsetLeft) {
            var scrollTo = containerScrollLeft - (containerOffsetLeft - tabsOffsetLeft);
            tabsContainer.animate({scrollLeft: scrollTo}, scrollDuration);
        }
        $('div.second-tabs-container:visible', secondTabsContainer).hide();
        $('#second_tabs_' + id).show();
        var wWidth = (window.innerWidth || (window.document.documentElement.clientWidth || window.document.body.clientWidth));
        var maxWidth = wWidth - secondTabsContainer.next().outerWidth();
        var secondTabs = $('#second_tabs_' + id);
        var secondTabsWidth = secondTabs.outerWidth();
        var left = tabsOffsetLeft + Math.floor(tabsWidth / 2) - Math.floor(secondTabsWidth / 2);
        left = Math.min(left, maxWidth - secondTabsWidth);
        left = Math.max(0, left);
        secondTabs.animate({left: left}, scrollDuration);
    }
})(jQuery);
/* "/static/js/jquery-1.10.2/mousewheel/jquery.mousewheel.min.js" */

!function (a) {
    "function" == typeof define && define.amd ? define(["jquery"], a) : "object" == typeof exports ? module.exports = a : a(jQuery)
}(function (a) {
    function b(b) {
        var g = b || window.event, h = i.call(arguments, 1), j = 0, l = 0, m = 0, n = 0, o = 0, p = 0;
        if (b = a.event.fix(g), b.type = "mousewheel", "detail"in g && (m = -1 * g.detail), "wheelDelta"in g && (m = g.wheelDelta), "wheelDeltaY"in g && (m = g.wheelDeltaY), "wheelDeltaX"in g && (l = -1 * g.wheelDeltaX), "axis"in g && g.axis === g.HORIZONTAL_AXIS && (l = -1 * m, m = 0), j = 0 === m ? l : m, "deltaY"in g && (m = -1 * g.deltaY, j = m), "deltaX"in g && (l = g.deltaX, 0 === m && (j = -1 * l)), 0 !== m || 0 !== l) {
            if (1 === g.deltaMode) {
                var q = a.data(this, "mousewheel-line-height");
                j *= q, m *= q, l *= q
            } else if (2 === g.deltaMode) {
                var r = a.data(this, "mousewheel-page-height");
                j *= r, m *= r, l *= r
            }
            if (n = Math.max(Math.abs(m), Math.abs(l)), (!f || f > n) && (f = n, d(g, n) && (f /= 40)), d(g, n) && (j /= 40, l /= 40, m /= 40), j = Math[j >= 1 ? "floor" : "ceil"](j / f), l = Math[l >= 1 ? "floor" : "ceil"](l / f), m = Math[m >= 1 ? "floor" : "ceil"](m / f), k.settings.normalizeOffset && this.getBoundingClientRect) {
                var s = this.getBoundingClientRect();
                o = b.clientX - s.left, p = b.clientY - s.top
            }
            return b.deltaX = l, b.deltaY = m, b.deltaFactor = f, b.offsetX = o, b.offsetY = p, b.deltaMode = 0, h.unshift(b, j, l, m), e && clearTimeout(e), e = setTimeout(c, 200), (a.event.dispatch || a.event.handle).apply(this, h)
        }
    }

    function c() {
        f = null
    }

    function d(a, b) {
        return k.settings.adjustOldDeltas && "mousewheel" === a.type && b % 120 === 0
    }

    var e, f, g = ["wheel", "mousewheel", "DOMMouseScroll", "MozMousePixelScroll"], h = "onwheel"in document || document.documentMode >= 9 ? ["wheel"] : ["mousewheel", "DomMouseScroll", "MozMousePixelScroll"], i = Array.prototype.slice;
    if (a.event.fixHooks)for (var j = g.length; j;)a.event.fixHooks[g[--j]] = a.event.mouseHooks;
    var k = a.event.special.mousewheel = {
        version: "3.1.12", setup: function () {
            if (this.addEventListener)for (var c = h.length; c;)this.addEventListener(h[--c], b, !1); else this.onmousewheel = b;
            a.data(this, "mousewheel-line-height", k.getLineHeight(this)), a.data(this, "mousewheel-page-height", k.getPageHeight(this))
        }, teardown: function () {
            if (this.removeEventListener)for (var c = h.length; c;)this.removeEventListener(h[--c], b, !1); else this.onmousewheel = null;
            a.removeData(this, "mousewheel-line-height"), a.removeData(this, "mousewheel-page-height")
        }, getLineHeight: function (b) {
            var c = a(b), d = c["offsetParent"in a.fn ? "offsetParent" : "parent"]();
            return d.length || (d = a("body")), parseInt(d.css("fontSize"), 10) || parseInt(c.css("fontSize"), 10) || 16
        }, getPageHeight: function (b) {
            return a(b).height()
        }, settings: {adjustOldDeltas: !0, normalizeOffset: !0}
    };
    a.fn.extend({
        mousewheel: function (a) {
            return a ? this.bind("mousewheel", a) : this.trigger("mousewheel")
        }, unmousewheel: function (a) {
            return this.unbind("mousewheel", a)
        }
    })
});